<?php
/**
 * Created by PhpStorm.
 * User: w-pc
 * Date: 2017/03/10
 * Time: 8:24
 */

namespace Home\Controller;
use Think\Controller;
class MessageController extends Controller {
    public function index(){
        $this->display();
    }
    public function index1(){
        $message_list = D('Message')->get_MessageList();
        $this->assign('message_list',$message_list);
        $this->display();
    }
    public function insert(){
        $m_email = request('post','str','m_email');
        $m_name = request('post','str','m_name');
        $m_photo = request('post','str','m_photo');
        $m_content = request('post','str','m_content');
        $m_time = date("Y-m-d h:i:sa");
        if($m_name==null||$m_content==null){
            echo "<script type='text/javascript'>alert('ID或内容未填写，请先填写内容！');</script>";
            $url="/index.php?c=message";
            echo "<script language=\"javascript\">";
            echo "location.href=\"$url\"";
            echo "</script>";
            exit();
        }
        if($m_photo==''){
            $m_photo = '/Public/home/images/userpic.gif';
        }else{
            $m_photo = 'http://q1.qlogo.cn/g?b=qq&nk='.$m_photo.'&s=140&t=1368862220';
        }
        $arr['m_email'] = $m_email;
        $arr['m_name'] = $m_name;
        $arr['m_photo'] = $m_photo;
        $arr['m_content'] = $m_content;
        $arr['m_time'] = $m_time;
        D('Message')->add_Message($arr);
        $this->redirect('/index.php?c=message');
    }
}